package base.sys.service;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import base.sys.api.enetity.SysMenu;
import base.sys.api.vo.SysMenuTree;
import base.sys.api.vo.UserInfo;

/**
 * @Description
 * @Author Pengwei
 * @CreatDate 2022/1/8 16:27
 */
@Service
public class SysService {
    @Autowired
    private SysMenuService baseSysMenuService;

    public UserInfo getUserInfoById(String userId) {
        List<SysMenu> list = baseSysMenuService.list(baseSysMenuService.getLambdaQuery().isNotNull(SysMenu::getPath));

        //获取路由信息
        List<SysMenu> routeList = baseSysMenuService.list().stream().filter(v -> StringUtils.isNotBlank(v.getPath())).toList();
        //获取用户的菜单树形结构
        List<SysMenuTree> menuList = baseSysMenuService.getSysMenuTree();

        return new UserInfo().setRouteList(routeList).setMenuList(menuList);
    }
}